# This code replicates Table 1
rm(list=ls())
setwd("")
library(foreign)
data <- read.dta("data.dta")

## Control villages
control_d <- data[which(data$treatment_catholic==1),]
row1 <- cbind(100*table(control_d$church_membership)[3]/sum(table(control_d$church_membership)), length(control_d[,1]))

## Adventist villages
adventist_d <- data[which(data$treatment_adventist==1),]
row2 <- cbind(100*table(adventist_d$church_membership)[1]/sum(table(adventist_d$church_membership)), length(adventist_d[,1]))

## Peruana villages
peruana_d <- data[which(data$treatment_peruana==1),]
row3 <- cbind(100*table(peruana_d$church_membership)[2]/sum(table(peruana_d$church_membership)), length(peruana_d[,1]))

## Maranatha villages
maranatha_d <- data[which(data$treatment_maranatha==1),]
row4 <- cbind(100*table(maranatha_d$church_membership)[4]/sum(table(maranatha_d$church_membership)), length(maranatha_d[,1]))

## Mixed villages
mixed_d <- data[which(data$treatment_mixed==1),]
row5 <- cbind(100*(table(mixed_d$church_membership)[1]+table(mixed_d$church_membership)[2]+table(mixed_d$church_membership)[4]+table(mixed_d$church_membership)[5])/sum(table(mixed_d$church_membership)), length(mixed_d[,1]))

table <- rbind(row1, row2, row3, row4, row5)
colnames(table) <- c("Compliance", "N")
rownames(table) <- c("Control", "Adventists", "Peruana", "Maranatha", "Mixed")
table <- round(table,1)
table


